package com.wh.publish;

import com.rabbitmq.client.Channel;
import com.wh.utils.ConnectionUtil;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Auther: HuiEr
 * @Date: 2020/3/11 20:46
 * @Description
 */
public class Producer {
    private static final String EXCHANGE_NAME="publish_subscribe_exchange";
    private static final String EXCHANGE_TYPE="fanout";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = ConnectionUtil.getConnection().createChannel();
        channel.exchangeDeclare(EXCHANGE_NAME,EXCHANGE_TYPE);
        for (int i=0;i<100;i++){
            channel.basicPublish(EXCHANGE_NAME,"",null,("发布订阅模型发送的消息    "+i).getBytes());
        }
    }
}
